package org.argeproje.resim.property;

import java.lang.reflect.InvocationTargetException;

import org.argeproje.resim.proc.data.KernelDA;
import org.eclipse.ui.views.properties.IPropertyDescriptor;

public class MatrixPRP extends Property{
	public MatrixPRP(Object owner,String propertyId,
			String displayName, String getterMethod, String setterMethod) {
		super(owner, propertyId, displayName, getterMethod, setterMethod);
		try {			
			_setterMethod = _owner.getClass().getMethod(setterMethod,String.class);
		} catch (SecurityException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NoSuchMethodException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		// TODO Auto-generated constructor stub
	}

	@Override
	public Object getValue() {
		try {
			return _getterMethod.invoke(_owner);
		} catch (IllegalArgumentException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public void setValue(Object value) {
		try {
			_setterMethod.invoke(_owner,value.toString());
		} catch (IllegalArgumentException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	@Override
	public IPropertyDescriptor getDescriptor() {
		MatrixPropertyDescriptor mpd = new MatrixPropertyDescriptor(_id,_displayName,new KernelDA(getValue().toString()));
		return mpd;
	}

}
